const http = uni.$u.http

const loginApi = {
  // 微信登录 传code
  async wxLogin(data?: object) {
    return await http.get('/wxLogin', { params: data })
  },
  // 注册
  async register(data?: object) {
    return await http.post('/insertWxUser', data)
  },
  // 获取token
  async getToken(data?: object) {
    let res = await http.post(
      '/admin/oauth2/token',
      {},
      {
        params: data,
        header: {
          Authorization: 'Basic dGVhY2hlcjp0ZWFjaGVy',
          'Content-type': 'application/x-www-form-urlencoded',
          isToken: false,
          grant_type: 'mobile',
        },
      }
    )
    return res
  },
  // 退出登录
  logout() {
    uni.clearStorageSync()
    uni.reLaunch({
      url: '/pages/login/index',
    })
  },
}

export default loginApi
